from pyspark import SparkContext,SparkConf

if __name__ == '__main__':
    conf=SparkConf().setMaster('local').setAppName('wordcount')

    sc=SparkContext(conf=conf)
    logFile='./1.txt'
    logData=sc.textFile(logFile,2).cache()
    numAs = logData.filter(lambda line: 'a' in line).count()
    numBs = logData.filter(lambda line: 'b' in line).count()

    print('A:'+str(numAs)+'  B:'+str(numBs))